<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
	<title>上传</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="${server}/static/css/bootstrap.min.css" rel="stylesheet">
	<link href="${server}/static/css/bootstrap_new.css" rel="stylesheet">
	<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
	<script type="text/javascript"  src="${server}/static/js/bootstrap.min.js"></script>
	<script type="text/javascript"  src="${server}/static/js/bootstrap_new.js"></script>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#hiddenFile').hide() ;
		
		$("form[name='upload-form']").submit(function(){
			// excel文件
			var quotationFile = $("input[name='quotationFile']").val();
			if(isEmpty(quotationFile)){
				alert("您还没有上传供货单");
				return false;
			}
			
			// 供应商
			var supplierId = $("select[name='supplierId']").val();
			if(isEmpty(supplierId)){
				alert("您还没有选择供应商");
				return false;
			}
			
			// 描述
			var quotationDesc = $("textarea[name='quotationDesc']").val();
			if(isEmpty(quotationDesc)){
				alert("您还没有填写描述");
				return false;
			}
			
			// 有效天数
			var quotationValid = $("input[name='quotationValid']").val();
			if(isEmpty(quotationValid)){
				alert("您还没有填写有效天数");
				return false;
			}
			
			// 折扣
			var quotationDiscount = $("input[name='quotationDiscount']").val();
			if(isEmpty(quotationDiscount)){
				alert("您还没有填写折扣");
				return false;
			}
			
			// 品牌
			var brandChkLength = $("input[name='brand']:checked").length;
			if(brandChkLength < 1){
				alert("您还没有选择品牌");
				return false;
			}
			
			return true;
		});
		
	});
	
	function isEmpty(value){
		if(value == null || value == "" || value == "undefined" || value == undefined || value == "null"){
			return true;
		}
		
		return false;
	}
	
	function choosefile(){
		$('#hiddenFile').click();
	}
	function ischoose(){
		var file =$('#hiddenFile').val();
		$('#file').val(file);
	}
	
	</script>
</head>
<body>

<%@include file="../common/header.jsp"%>

<div id="myTabContent" class="tab-content">
	<div class="tab-pane fade in active" id="excelimport">
		<div style="padding: 20px 100px 10px;">
		   <form class="form-horizontal" role="form" action="${server}/quotation/add" method="post" enctype="multipart/form-data" name="upload-form">
		   
		   		<div class="form-group">
					<label class="col-sm-1 control-label">供货单</label>
					<span class="col-sm-4">
						 <div class="input-group">
				         <input type="file"  id="hiddenFile" name="quotationFile" onchange="javascript:ischoose(this);">
		          		<input type="text" id="file" class="form-control" placeholder="选择文件" onclick="javascript:choosefile();">
				         <span class="input-group-addon" style=" background-color: #fff;  border: 0px solid #ccc; "><button type="button" class="btn"  onclick="javascript:choosefile();">浏览</button></span>
				      	</div>
					</span>
				</div>
				 <br>
				 
				<div class="form-group">
					<label class="col-sm-1 control-label">供应商</label>
					<span class="col-sm-3">
						<!-- <input type="text" name="supplierId" value="" class="form-control"> -->
						<select name="supplierId" class="form-control">
							<option value="">请选择</option>
							<c:forEach items="${suppliers}" var="supplier">
								<option value="${supplier.supplierId}">${supplier.supplierName}</option>
							</c:forEach>
						</select>
					</span>
				</div>
				 <br>
				 
				<div class="form-group">
					<label  class="col-sm-1 control-label" for="name">描述</label>
					<span class="col-sm-4">
					<textarea class="form-control" rows="4" name="quotationDesc"></textarea>
					</span>
					<label class="col-sm-1 control-label">有效天数</label>
					<span class="col-sm-1">
						<input type="text" name="quotationValid" class="form-control" >
					</span>
					<label class="col-sm-1 control-label">折扣</label>
					<span class="col-sm-1">
						 <input type="text" name="quotationDiscount" class="form-control" >
					</span>
				</div>
				 <br>
				 
				 <div class="form-group"> 
					<label class="col-sm-1 control-label">品牌</label>
					<span class="col-sm-3">
						<!-- <input type="text" name="brand" value="" class="form-control" > -->
						<div class="checkbox">
							<c:forEach items="${brands}" var="brand">
								<label>
									<input type="checkbox" name="brand" value="${brand.brandId}"/>${brand.brandName}
								</label>
							</c:forEach>
						</div>
					</span>
				</div>
				 <br>
		
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn  btn-primary" contenteditable="true">上传</button>
						</div>
					</div>
				</form>
		</div>
	</div>
</div>



</body>

	
</html>
